﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace BDH.DAL
{
    public class ThanhvienDAL : BaseDAL
    {
        public object GetByKey(object key)
        {
            var sql = @" SELECT id,taikhoan,matkhau,hoten,vaitro FROM thanhvien WHERE taikhoan = '{0}' ";
            sql = String.Format(sql, key);
            var tbl = ExecuteQuery(sql);

            if (tbl.Rows.Count > 0)
            {
                var usr = new Entities.Thanhvien();
                usr.taikhoan = tbl.Rows[0]["taikhoan"] + "";
                usr.matkhau = tbl.Rows[0]["matkhau"] + "";
                usr.hoten = tbl.Rows[0]["hoten"] + "";
                usr.vaitro = tbl.Rows[0]["vaitro"] + "";
                return usr;
            }
            else return null;
        }
    }
}
